<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>EasyQtSql: Database Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">EasyQtSql
   </div>
   <div id="projectbrief">Easy SQL data access helper for QtSql</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('class_database.htm','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a> &#124;
<a href="class_database-members.htm">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">Database Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>QSqlDatabase wrapper.  
 <a href="class_database.htm#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="_easy_qt_sql___transaction_8h_source.htm">EasyQtSql_Transaction.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for Database:</div>
<div class="dyncontent">
 <div class="center">
  <img src="class_database.png" usemap="#Database_map" alt=""/>
  <map id="Database_map" name="Database_map">
<area href="class_transaction.htm" title="QSqlDatabase transaction wrapper. " alt="Transaction" shape="rect" coords="0,56,78,80"/>
</map>
 </div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a252b2bb8aeb0c0a2509b0eddf0be3c4e"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_database.htm#a252b2bb8aeb0c0a2509b0eddf0be3c4e">Database</a> (const QSqlDatabase &amp;db=QSqlDatabase())</td></tr>
<tr class="separator:a252b2bb8aeb0c0a2509b0eddf0be3c4e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afe82d7c8e0e895c0b4f9fa08b4e3eb8e"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_database.htm#afe82d7c8e0e895c0b4f9fa08b4e3eb8e">Database</a> (<a class="el" href="class_database.htm">Database</a> &amp;&amp;other)</td></tr>
<tr class="separator:afe82d7c8e0e895c0b4f9fa08b4e3eb8e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2a81e06933bf2ef5be2e59030a7e1e1c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_database.htm">Database</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_database.htm#a2a81e06933bf2ef5be2e59030a7e1e1c">operator=</a> (<a class="el" href="class_database.htm">Database</a> &amp;&amp;other)</td></tr>
<tr class="separator:a2a81e06933bf2ef5be2e59030a7e1e1c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7bc0ce48d3711002d4e0490c826f7b5e"><td class="memItemLeft" align="right" valign="top">QSqlError&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_database.htm#a7bc0ce48d3711002d4e0490c826f7b5e">lastError</a> () const</td></tr>
<tr class="memdesc:a7bc0ce48d3711002d4e0490c826f7b5e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns information about the last error that occurred on the underlying database.  <a href="#a7bc0ce48d3711002d4e0490c826f7b5e">More...</a><br /></td></tr>
<tr class="separator:a7bc0ce48d3711002d4e0490c826f7b5e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aae9f7e53275334c91655eeb7a2bde030"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_non_query_result.htm">NonQueryResult</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_database.htm#aae9f7e53275334c91655eeb7a2bde030">execNonQuery</a> (const QString &amp;sql) const</td></tr>
<tr class="memdesc:aae9f7e53275334c91655eeb7a2bde030"><td class="mdescLeft">&#160;</td><td class="mdescRight">Executes non-query SQL statement (DELETE, INSERT, UPDATE, CREATE, ALTER, etc.)  <a href="#aae9f7e53275334c91655eeb7a2bde030">More...</a><br /></td></tr>
<tr class="separator:aae9f7e53275334c91655eeb7a2bde030"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a05c1ac255cdba9781f8bf306801bca70"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_query_result.htm">QueryResult</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_database.htm#a05c1ac255cdba9781f8bf306801bca70">execQuery</a> (const QString &amp;sql) const</td></tr>
<tr class="memdesc:a05c1ac255cdba9781f8bf306801bca70"><td class="mdescLeft">&#160;</td><td class="mdescRight">Executes SELECT query.  <a href="#a05c1ac255cdba9781f8bf306801bca70">More...</a><br /></td></tr>
<tr class="separator:a05c1ac255cdba9781f8bf306801bca70"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8388689590c1f3adeabd2972b221bcb2"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_insert_query.htm">InsertQuery</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_database.htm#a8388689590c1f3adeabd2972b221bcb2">insertInto</a> (const QString &amp;table) const</td></tr>
<tr class="memdesc:a8388689590c1f3adeabd2972b221bcb2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates INSERT query wrapper.  <a href="#a8388689590c1f3adeabd2972b221bcb2">More...</a><br /></td></tr>
<tr class="separator:a8388689590c1f3adeabd2972b221bcb2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a44fca4a9c9241481a87d59f529e98b9e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_delete_query.htm">DeleteQuery</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_database.htm#a44fca4a9c9241481a87d59f529e98b9e">deleteFrom</a> (const QString &amp;table) const</td></tr>
<tr class="memdesc:a44fca4a9c9241481a87d59f529e98b9e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates DELETE query wrapper.  <a href="#a44fca4a9c9241481a87d59f529e98b9e">More...</a><br /></td></tr>
<tr class="separator:a44fca4a9c9241481a87d59f529e98b9e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2d8dad3df4134306749582216bd437e0"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_update_query.htm">UpdateQuery</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_database.htm#a2d8dad3df4134306749582216bd437e0">update</a> (const QString &amp;table) const</td></tr>
<tr class="memdesc:a2d8dad3df4134306749582216bd437e0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates UPDATE query wrapper.  <a href="#a2d8dad3df4134306749582216bd437e0">More...</a><br /></td></tr>
<tr class="separator:a2d8dad3df4134306749582216bd437e0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a03e2c9113452bb52bb7018ef2366bce1"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_prepared_query.htm">PreparedQuery</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_database.htm#a03e2c9113452bb52bb7018ef2366bce1">prepare</a> (const QString &amp;sql, bool forwardOnly=true) const</td></tr>
<tr class="memdesc:a03e2c9113452bb52bb7018ef2366bce1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Prepares SQL statement.  <a href="#a03e2c9113452bb52bb7018ef2366bce1">More...</a><br /></td></tr>
<tr class="separator:a03e2c9113452bb52bb7018ef2366bce1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0076431e130f7815ca7a3ae8ec7284ef"><td class="memItemLeft" align="right" valign="top">QSqlDatabase &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_database.htm#a0076431e130f7815ca7a3ae8ec7284ef">qSqlDatabase</a> ()</td></tr>
<tr class="memdesc:a0076431e130f7815ca7a3ae8ec7284ef"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a reference to the wrapped QSqlDatabase object.  <a href="#a0076431e130f7815ca7a3ae8ec7284ef">More...</a><br /></td></tr>
<tr class="separator:a0076431e130f7815ca7a3ae8ec7284ef"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7a13f4fc603fb829f123894d9abd6ea7"><td class="memTemplParams" colspan="2">template&lt;typename Func &gt; </td></tr>
<tr class="memitem:a7a13f4fc603fb829f123894d9abd6ea7"><td class="memTemplItemLeft" align="right" valign="top">int&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_database.htm#a7a13f4fc603fb829f123894d9abd6ea7">each</a> (const QString &amp;query, Func &amp;&amp;f) const</td></tr>
<tr class="memdesc:a7a13f4fc603fb829f123894d9abd6ea7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Executes <em>query</em> and applies function <em>f</em> to each result row.  <a href="#a7a13f4fc603fb829f123894d9abd6ea7">More...</a><br /></td></tr>
<tr class="separator:a7a13f4fc603fb829f123894d9abd6ea7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad2283c7025501aafc33530d19beb02b4"><td class="memTemplParams" colspan="2">template&lt;typename Func &gt; </td></tr>
<tr class="memitem:ad2283c7025501aafc33530d19beb02b4"><td class="memTemplItemLeft" align="right" valign="top">int&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_database.htm#ad2283c7025501aafc33530d19beb02b4">first</a> (const QString &amp;query, Func &amp;&amp;f) const</td></tr>
<tr class="memdesc:ad2283c7025501aafc33530d19beb02b4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Executes <em>query</em> and applies function <em>f</em> to the first result row.  <a href="#ad2283c7025501aafc33530d19beb02b4">More...</a><br /></td></tr>
<tr class="separator:ad2283c7025501aafc33530d19beb02b4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3b1fb50c3263775351fc981fda798207"><td class="memTemplParams" colspan="2">template&lt;typename Func &gt; </td></tr>
<tr class="memitem:a3b1fb50c3263775351fc981fda798207"><td class="memTemplItemLeft" align="right" valign="top">int&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_database.htm#a3b1fb50c3263775351fc981fda798207">range</a> (const QString &amp;query, int start, int count, Func &amp;&amp;f) const</td></tr>
<tr class="memdesc:a3b1fb50c3263775351fc981fda798207"><td class="mdescLeft">&#160;</td><td class="mdescRight">Executes <em>query</em> and applies function <em>f</em> to <em>count</em> result rows starting from index <em>start</em>.  <a href="#a3b1fb50c3263775351fc981fda798207">More...</a><br /></td></tr>
<tr class="separator:a3b1fb50c3263775351fc981fda798207"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a91583d42e701fb399563facc3c3c58c0"><td class="memTemplParams" colspan="2">template&lt;typename Func &gt; </td></tr>
<tr class="memitem:a91583d42e701fb399563facc3c3c58c0"><td class="memTemplItemLeft" align="right" valign="top">int&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_database.htm#a91583d42e701fb399563facc3c3c58c0">top</a> (const QString &amp;query, int topCount, Func &amp;&amp;f) const</td></tr>
<tr class="memdesc:a91583d42e701fb399563facc3c3c58c0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Executes <em>query</em> and applies function <em>f</em> to <em>topCount</em> result rows.  <a href="#a91583d42e701fb399563facc3c3c58c0">More...</a><br /></td></tr>
<tr class="separator:a91583d42e701fb399563facc3c3c58c0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a909783661db7d15e0b0adca5a96db4de"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:a909783661db7d15e0b0adca5a96db4de"><td class="memTemplItemLeft" align="right" valign="top">T&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_database.htm#a909783661db7d15e0b0adca5a96db4de">scalar</a> (const QString &amp;query) const</td></tr>
<tr class="memdesc:a909783661db7d15e0b0adca5a96db4de"><td class="mdescLeft">&#160;</td><td class="mdescRight">Executes <em>query</em> and returns scalar value converted to T.  <a href="#a909783661db7d15e0b0adca5a96db4de">More...</a><br /></td></tr>
<tr class="separator:a909783661db7d15e0b0adca5a96db4de"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a39dbcd9a97f4e3c38c8c5ba48e445216"><td class="memItemLeft" align="right" valign="top">QVariant&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_database.htm#a39dbcd9a97f4e3c38c8c5ba48e445216">scalar</a> (const QString &amp;query) const</td></tr>
<tr class="memdesc:a39dbcd9a97f4e3c38c8c5ba48e445216"><td class="mdescLeft">&#160;</td><td class="mdescRight">Executes <em>query</em> and returns scalar value.  <a href="#a39dbcd9a97f4e3c38c8c5ba48e445216">More...</a><br /></td></tr>
<tr class="separator:a39dbcd9a97f4e3c38c8c5ba48e445216"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr class="memitem:a7357cbeca05937556f66e2fe2288bdb5"><td class="memItemLeft" align="right" valign="top">QSqlDatabase&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a></td></tr>
<tr class="separator:a7357cbeca05937556f66e2fe2288bdb5"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>QSqlDatabase wrapper. </p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> test()</div><div class="line">{</div><div class="line">   QSqlDatabase db = QSqlDatabase::addDatabase(<span class="stringliteral">&quot;QSQLITE&quot;</span>);</div><div class="line">   db.setDatabaseName(<span class="stringliteral">&quot;:memory:&quot;</span>);</div><div class="line"></div><div class="line">   <span class="keywordflow">try</span></div><div class="line">   {</div><div class="line">      <a class="code" href="class_database.htm">Database</a> sdb(db);</div><div class="line"></div><div class="line">      sdb.execNonQuery(<span class="stringliteral">&quot;CREATE TABLE table (a int, b int, c int, d text)&quot;</span>);</div><div class="line">   }</div><div class="line">   <span class="keywordflow">catch</span> (<span class="keyword">const</span> <a class="code" href="class_d_b_exception.htm">DBException</a> &amp;e)</div><div class="line">   {</div><div class="line">      <span class="comment">//you can handle all the errors at one point</span></div><div class="line"></div><div class="line">      qDebug() &lt;&lt; e.<a class="code" href="class_d_b_exception.htm#adf142ded3fb236826a5a6ba4a606e584">lastError</a> &lt;&lt; e.<a class="code" href="class_d_b_exception.htm#a3ec8b4b593abee155554472ae0b58f12">lastQuery</a>;</div><div class="line">   }</div><div class="line">}</div></div><!-- fragment --> </div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a252b2bb8aeb0c0a2509b0eddf0be3c4e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a252b2bb8aeb0c0a2509b0eddf0be3c4e">&#9670;&nbsp;</a></span>Database() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">Database::Database </td>
          <td>(</td>
          <td class="paramtype">const QSqlDatabase &amp;&#160;</td>
          <td class="paramname"><em>db</em> = <code>QSqlDatabase()</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">explicit</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">db</td><td>QSqlDatabase to use</td></tr>
  </table>
  </dd>
</dl>
<p>Creates an <a class="el" href="class_database.htm" title="QSqlDatabase wrapper. ">Database</a> object, tries to open <em>db</em> connection if not opened.</p>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="class_d_b_exception.htm" title="Exception class for SQL errors handling. ">DBException</a></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="afe82d7c8e0e895c0b4f9fa08b4e3eb8e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afe82d7c8e0e895c0b4f9fa08b4e3eb8e">&#9670;&nbsp;</a></span>Database() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">Database::Database </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="class_database.htm">Database</a> &amp;&amp;&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a44fca4a9c9241481a87d59f529e98b9e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a44fca4a9c9241481a87d59f529e98b9e">&#9670;&nbsp;</a></span>deleteFrom()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_delete_query.htm">DeleteQuery</a> Database::deleteFrom </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>table</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Creates DELETE query wrapper. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">table</td><td>Table to delete from </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a7a13f4fc603fb829f123894d9abd6ea7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7a13f4fc603fb829f123894d9abd6ea7">&#9670;&nbsp;</a></span>each()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename Func &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int Database::each </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>query</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Func &amp;&amp;&#160;</td>
          <td class="paramname"><em>f</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Executes <em>query</em> and applies function <em>f</em> to each result row. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">query</td><td>SQL query string (SELECT statement) </td></tr>
    <tr><td class="paramname">f</td><td>Function (lambda) to apply to </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>num rows handled with function <em>f</em></dd></dl>
<div class="fragment"><div class="line"><a class="code" href="class_database.htm">Database</a> db;</div><div class="line">db.<a class="code" href="class_database.htm#a7a13f4fc603fb829f123894d9abd6ea7">each</a>(<span class="stringliteral">&quot;SELECT * FROM table&quot;</span>, [](<span class="keyword">const</span> <a class="code" href="class_query_result.htm">QueryResult</a> &amp;res)</div><div class="line">{</div><div class="line">   qDebug() &lt;&lt; res.<a class="code" href="class_query_result.htm#a023bd84f7010368d616d7dbb1b399a06">toMap</a>();</div><div class="line">});</div></div><!-- fragment --> 
</div>
</div>
<a id="aae9f7e53275334c91655eeb7a2bde030"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aae9f7e53275334c91655eeb7a2bde030">&#9670;&nbsp;</a></span>execNonQuery()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_non_query_result.htm">NonQueryResult</a> Database::execNonQuery </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>sql</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Executes non-query SQL statement (DELETE, INSERT, UPDATE, CREATE, ALTER, etc.) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">query</td><td>SQL statement string </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="class_d_b_exception.htm" title="Exception class for SQL errors handling. ">DBException</a></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a05c1ac255cdba9781f8bf306801bca70"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a05c1ac255cdba9781f8bf306801bca70">&#9670;&nbsp;</a></span>execQuery()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_query_result.htm">QueryResult</a> Database::execQuery </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>sql</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Executes SELECT query. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">query</td><td>SQL statement string </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="class_d_b_exception.htm" title="Exception class for SQL errors handling. ">DBException</a></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ad2283c7025501aafc33530d19beb02b4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad2283c7025501aafc33530d19beb02b4">&#9670;&nbsp;</a></span>first()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename Func &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int Database::first </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>query</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Func &amp;&amp;&#160;</td>
          <td class="paramname"><em>f</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Executes <em>query</em> and applies function <em>f</em> to the first result row. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">query</td><td>SQL query string (SELECT statement) </td></tr>
    <tr><td class="paramname">f</td><td>Function (lambda) to apply to </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>num rows handled with function <em>f</em></dd></dl>
<div class="fragment"><div class="line"><a class="code" href="class_database.htm">Database</a> db;</div><div class="line">db.<a class="code" href="class_database.htm#ad2283c7025501aafc33530d19beb02b4">first</a>(<span class="stringliteral">&quot;SELECT * FROM table&quot;</span>, [](<span class="keyword">const</span> <a class="code" href="class_query_result.htm">QueryResult</a> &amp;res)</div><div class="line">{</div><div class="line">   qDebug() &lt;&lt; res.<a class="code" href="class_query_result.htm#a023bd84f7010368d616d7dbb1b399a06">toMap</a>();</div><div class="line">});</div></div><!-- fragment --> 
</div>
</div>
<a id="a8388689590c1f3adeabd2972b221bcb2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8388689590c1f3adeabd2972b221bcb2">&#9670;&nbsp;</a></span>insertInto()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_insert_query.htm">InsertQuery</a> Database::insertInto </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>table</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Creates INSERT query wrapper. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">table</td><td>Table to insert into with list of columns </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a7bc0ce48d3711002d4e0490c826f7b5e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7bc0ce48d3711002d4e0490c826f7b5e">&#9670;&nbsp;</a></span>lastError()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">QSqlError Database::lastError </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Returns information about the last error that occurred on the underlying database. </p>

</div>
</div>
<a id="a2a81e06933bf2ef5be2e59030a7e1e1c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2a81e06933bf2ef5be2e59030a7e1e1c">&#9670;&nbsp;</a></span>operator=()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_database.htm">Database</a>&amp; Database::operator= </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="class_database.htm">Database</a> &amp;&amp;&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<a id="a03e2c9113452bb52bb7018ef2366bce1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a03e2c9113452bb52bb7018ef2366bce1">&#9670;&nbsp;</a></span>prepare()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_prepared_query.htm">PreparedQuery</a> Database::prepare </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>sql</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>forwardOnly</em> = <code>true</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Prepares SQL statement. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sql</td><td>SQL statement string </td></tr>
    <tr><td class="paramname">forwardOnly</td><td>Configure underlying QSqlQuery as forwardOnly </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a0076431e130f7815ca7a3ae8ec7284ef"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0076431e130f7815ca7a3ae8ec7284ef">&#9670;&nbsp;</a></span>qSqlDatabase()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">QSqlDatabase&amp; Database::qSqlDatabase </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Returns a reference to the wrapped QSqlDatabase object. </p>

</div>
</div>
<a id="a3b1fb50c3263775351fc981fda798207"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3b1fb50c3263775351fc981fda798207">&#9670;&nbsp;</a></span>range()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename Func &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int Database::range </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>query</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>start</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>count</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Func &amp;&amp;&#160;</td>
          <td class="paramname"><em>f</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Executes <em>query</em> and applies function <em>f</em> to <em>count</em> result rows starting from index <em>start</em>. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">query</td><td>SQL query string (SELECT statement) </td></tr>
    <tr><td class="paramname">start</td><td>Start index </td></tr>
    <tr><td class="paramname">count</td><td>Row count to handle </td></tr>
    <tr><td class="paramname">f</td><td>Function (lambda) to apply to </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>num rows handled with function <em>f</em></dd></dl>
<div class="fragment"><div class="line"><a class="code" href="class_database.htm">Database</a> db;</div><div class="line">db.<a class="code" href="class_database.htm#a3b1fb50c3263775351fc981fda798207">range</a>(<span class="stringliteral">&quot;SELECT * FROM table&quot;</span>, 3, 10, [](<span class="keyword">const</span> <a class="code" href="class_query_result.htm">QueryResult</a> &amp;res)</div><div class="line">{</div><div class="line">   qDebug() &lt;&lt; res.<a class="code" href="class_query_result.htm#a023bd84f7010368d616d7dbb1b399a06">toMap</a>();</div><div class="line">});</div></div><!-- fragment --> 
</div>
</div>
<a id="a909783661db7d15e0b0adca5a96db4de"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a909783661db7d15e0b0adca5a96db4de">&#9670;&nbsp;</a></span>scalar() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">T Database::scalar </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>query</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Executes <em>query</em> and returns scalar value converted to T. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">query</td><td>SQL query string (SELECT statement) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="class_query_result.htm#a5e3b49cb821efecac406606d9e3adb13" title="Returns scalar value converted to type T (the value of the first column of the current row) ...">QueryResult::scalar</a> </dd></dl>

</div>
</div>
<a id="a39dbcd9a97f4e3c38c8c5ba48e445216"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a39dbcd9a97f4e3c38c8c5ba48e445216">&#9670;&nbsp;</a></span>scalar() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">QVariant Database::scalar </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>query</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Executes <em>query</em> and returns scalar value. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">query</td><td>SQL query string (SELECT statement) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="class_query_result.htm#a5e3b49cb821efecac406606d9e3adb13" title="Returns scalar value converted to type T (the value of the first column of the current row) ...">QueryResult::scalar</a> </dd></dl>

</div>
</div>
<a id="a91583d42e701fb399563facc3c3c58c0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a91583d42e701fb399563facc3c3c58c0">&#9670;&nbsp;</a></span>top()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename Func &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int Database::top </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>query</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>topCount</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Func &amp;&amp;&#160;</td>
          <td class="paramname"><em>f</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Executes <em>query</em> and applies function <em>f</em> to <em>topCount</em> result rows. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">query</td><td>SQL query string (SELECT statement) </td></tr>
    <tr><td class="paramname">topCount</td><td>Row count to handle </td></tr>
    <tr><td class="paramname">f</td><td>Function (lambda) to apply to </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>num rows handled with function <em>f</em></dd></dl>
<div class="fragment"><div class="line"><a class="code" href="class_database.htm">Database</a> db;</div><div class="line">db.<a class="code" href="class_database.htm#a91583d42e701fb399563facc3c3c58c0">top</a>(<span class="stringliteral">&quot;SELECT * FROM table&quot;</span>, 10, [](<span class="keyword">const</span> <a class="code" href="class_query_result.htm">QueryResult</a> &amp;res)</div><div class="line">{</div><div class="line">   qDebug() &lt;&lt; res.<a class="code" href="class_query_result.htm#a023bd84f7010368d616d7dbb1b399a06">toMap</a>();</div><div class="line">});</div></div><!-- fragment --> 
</div>
</div>
<a id="a2d8dad3df4134306749582216bd437e0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2d8dad3df4134306749582216bd437e0">&#9670;&nbsp;</a></span>update()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_update_query.htm">UpdateQuery</a> Database::update </td>
          <td>(</td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>table</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Creates UPDATE query wrapper. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">table</td><td>Table to update </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<h2 class="groupheader">Member Data Documentation</h2>
<a id="a7357cbeca05937556f66e2fe2288bdb5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7357cbeca05937556f66e2fe2288bdb5">&#9670;&nbsp;</a></span>m_db</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">QSqlDatabase Database::m_db</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>EasyQtSql/<a class="el" href="_easy_qt_sql___transaction_8h_source.htm">EasyQtSql_Transaction.h</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="class_database.htm">Database</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
  </ul>
</div>
</body>
</html>
